#/bin/sh

#编译
gcc Ex2_1.c -o Ex2_1 -lm -fopenmp -O3
mpicc Ex2_2.c -o Ex2_2 -lm -O3

#运行OpenMP版本
echo 1000 				>> out1.txt;		#1000
for((i=1; i<= 8; i++));
do
	export OMP_NUM_THREADS=$i;				#设置OpenMP的处理器数
	./Ex2_1 1000 1		>> out1.txt;
done;

echo 10000 				>> out1.txt;		#10000
for((i=1; i<= 8; i++));
do
	export OMP_NUM_THREADS=$i;				#设置OpenMP的处理器数
	./Ex2_1 10000 10	>> out1.txt;
done;

echo 20000 				>> out1.txt;		#20000
for((i=1; i<= 8; i++));
do
	export OMP_NUM_THREADS=$i;				#设置OpenMP的处理器数
	./Ex2_1 20000 20	>> out1.txt;
done;

echo 30000 				>> out1.txt;		#30000
for((i=1; i<= 8; i++));
do
	export OMP_NUM_THREADS=$i;				#设置OpenMP的处理器数
	./Ex2_1 30000 30	>> out1.txt;
done;

#MPI版本
for((i=12; i<= 240; i=i+12));			#1000
do
	bsub -a intelmpi -q short -o ./out2.1000_$i -n $i mpirun.lsf ./Ex2_2 1000 1;
done;

for((i=12; i<= 120; i=i+12));			#10000
do
	bsub -a intelmpi -q short -o ./out2.10000_$i -n $i mpirun.lsf ./Ex2_2 10000 10;
done;

for((i=12; i<= 120; i=i+12));			#20000
do
	bsub -a intelmpi -q short -o ./out2.20000_$i -n $i mpirun.lsf ./Ex2_2 20000 20;
done;

for((i=12; i<= 120; i=i+12));			#30000
do
	bsub -a intelmpi -q short -o ./out2.30000_$i -n $i mpirun.lsf ./Ex2_2 30000 30;
done;
